package cn.huiyunche.admin.security;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

import cn.huiyunche.base.service.framework.exception.AppError;
import cn.huiyunche.base.service.framework.utils.AppUtils;

/**
 * 当用户没经过认证或者认证失败时会调用comence方法.
 * <p>
 * 返回对应的错误的json.
 *
 *
 * @author zhaoshb
 * @since 0.0.1
 */
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint {

	public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) throws IOException, ServletException {
		AppUtils.responseErrorJson(response, AppError.AuthenticationInvalidError);
	}

}
